package cn.ictgu.dao.mapper;

import cn.ictgu.dao.model.Video;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Video 数据库映射
 * Created by Silence on 2016/11/28.
 */
@Mapper
public interface VideoMapper {

  @Select("SELECT * FROM video WHERE type = #{type} ORDER BY id DESC LIMIT #{index}, #{size}")
  List<Video> selectByType(@Param("type") String type, @Param("index") int index, @Param("size") int size);

  @Select("SELECT * FROM video WHERE type = #{type} ORDER BY id DESC LIMIT 1")
  Video selctOneByType(@Param("type") String type);

  @Select("SELECT * FROM video WHERE type LIKE CONCAT(#{type},'%') ORDER BY id DESC LIMIT #{index}, #{size}")
  List<Video> selectLikeType(@Param("type") String type, @Param("index") int index, @Param("size") int size);


  @Select("SELECT * FROM video WHERE id = #{id} LIMIT 1")
  Video selectById(long id);

}
